home *** CD-ROM | disk | FTP | other *** search
/ Apple Developer Connection Student Program / ADC Tools Sampler CD Disk 3 1999.iso / Metrowerks CodeWarrior / Java Support / Java_Source / IFC_112 / netscape / application / HRTextAttachment.java < prev    next >
Encoding:
Text File  |  1999-05-28  |  1.1 KB  |  48 lines  |  [TEXT/CWIE]

  1. // HRTextAttachment.java
  2. // By Ned Etcode
  3. // Copyright 1995, 1996, 1997 Netscape Communications Corp.  All rights reserved.
  4.  
  5. package netscape.application;
  6.  
  7. import netscape.util.*;
  8.  
  9.  
  10. /** TextAttachment subclass to display an horizontal rule.
  11.   * @see TextAttachment
  12.   * @private
  13.   */
  14. public class HRTextAttachment extends TextAttachment {
  15.     private static int WIDTH_OFFSET=10;
  16.     private static int HEIGHT = 12;
  17.  
  18.     public HRTextAttachment() {
  19.         super();
  20.     }
  21.     public int width() {
  22.         return owner().width();
  23.     }
  24.  
  25.     public int height() {
  26.         return HEIGHT;
  27.     }
  28.     public void drawInRect(Graphics g, Rect boundsRect) {
  29.         Rect r = new Rect();
  30.         if (g == null || boundsRect == null) {
  31.             return;
  32.         }
  33.         r.x = boundsRect.x + WIDTH_OFFSET;
  34.         r.width = boundsRect.width - (2*WIDTH_OFFSET);
  35.         r.height = 2;
  36.         r.y = boundsRect.y + ((HEIGHT - 2) / 2);
  37.         g.setColor(Color.darkGray);
  38.         g.fillRect( r );
  39.         r.y++;
  40.         r.height = 1;
  41.         g.setColor(Color.lightGray);
  42.         g.fillRect( r );
  43.     }
  44. }
  45.  
  46.  
  47.  
  48.